class Solution {
    public ListNode removeZeroSumSublists(ListNode head) {
       ListNode newHead = new ListNode(0);
       newHead.next = head ;
       ListNode pre = newHead ;
       while(pre != null){
        ListNode p = pre.next ;
        int sum = 0 ;
         while(p != null){
          sum += p.val ;
          if(sum == 0){
          pre.next = p.next ;
          break ;
          }
          p = p.next ;
         }
         if(p == null){
            pre = pre.next ;
         }
       }
       return newHead.next ;

    }
    

}